package com.lcj.aoch.rule.controller;

import com.lcj.aoch.rule.config.ConstantConfiguration;
import com.lcj.aoch.rule.controller.form.CalculateIncentiveFeeForm;
import com.lcj.aoch.rule.service.AwardRuleService;
import com.lcj.common.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import javax.annotation.Resource;
import javax.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/award"})
@Tag(name = "AwardRuleController", description = "系统奖励规则Web接口")
public class AwardRuleController {
  @Resource
  private AwardRuleService awardRuleService;

  @Resource
  private ConstantConfiguration constantConfiguration;

  @PostMapping({"/calculateIncentiveFee"})
  @Operation(summary = "计算系统奖励")
  public Result calculateIncentiveFee(@RequestBody @Valid CalculateIncentiveFeeForm calculateIncentiveFeeForm) {
    String res = this.awardRuleService.calculateIncentiveFee(
            calculateIncentiveFeeForm.getDriverId(),
            calculateIncentiveFeeForm.getAcceptTime(),
            constantConfiguration.getAesKey());
    return Result.ok().put("result", res);
  }
}
